package org.example.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspect {

    @Pointcut("execution(* org.example.*.*.*(..))")
    public void myAdviceExpression() {
    }

    @Before("myAdviceExpression()")
    public void doBefore(JoinPoint joinPoint) {
        System.out.println("前置增强");
        System.out.println("目标对象："+joinPoint.getTarget() + joinPoint.getSignature().getDeclaringTypeName());
    }
    @After("myAdviceExpression()")
    public void doAfter() {
        System.out.println("后置增强");
    }
}
